<template>
    <div class="box">
    <div class="header">
      <van-nav-bar title="订单" left-arrow @click-left="$router.back()" />
    </div>
    <div class="content">
     <van-cell title="张三 121435678956" label="昌平区南口" is-link />
   <van-swipe-cell  v-for="item in store.orderList" :key="item.id" @click="$router.push('/order/detail/'+item.id)">
  <van-card
   :num="item.count"
          :price="item.price"
         
          :title="item.title"
        
          :thumb="item.image"
  />

</van-swipe-cell>
  </div>
    <van-submit-bar :price="store.totalPrice*100" button-text="支付" @submit="onSubmit" />
    </div>
</template>

<script setup>
import { useCounterStore } from "@/stores/counter";
import request from '@/utils/request'
const store = useCounterStore();

const onSubmit=()=>{
     const obj = {
        id:new Date().getTime(),
        title:'NO'+new Date().getTime(),
        price:store.totalPrice
     }
     store.addOrderList({
        ...obj,
        status:1,
        orderList:store.orderList
     })
     request.get('/pay',{
        params:obj
     }).then(res=>{
        if(res.data.code==200)
        {
            window.location.href=res.data.data
        }
     })
    
}
</script>

<style lang="scss" scoped>

</style>